// pages/member/follow/component/follow.js
import {talentFollowSave} from '../../../../api/member'
Component({
  /**
   * 组件的属性列表
   */
  
  properties: {
      info:{
        type:Array
      }
  },
  pageLifetimes:{

  },
  lifetimes:{
    attached(){

    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    fansList:[]
  },

  /**
   * 组件的方法列表
   */
  methods: {
   

    loveClick(e) {
      var followType=e.currentTarget.dataset.type
      var content=''
      if(e.currentTarget.dataset.type=='true'){
          content='关注成功'
      }else if(e.currentTarget.dataset.type=='false'){
        content='已取消关注'
      }
      console.log(content)
      talentFollowSave({
        follow: followType,
        talentId: e.currentTarget.dataset.id
      }).then(res => {
        if(res.type=='success'){
          wx.showToast({
            title: content,
            icon: 'success',
            duration: 1000
          })
          if(followType=='false'){
            this.data.info[e.currentTarget.dataset.index].isFollow=false
          }else if(followType=='true'){
            this.data.info[e.currentTarget.dataset.index].isFollow=true
          }
          this.setData({
            info:this.data.info
          })
        }

      })
    },
    toDetail(data){
      wx.navigateTo({
        url: '/pages/member/follow/dynamic/index?id='+data.currentTarget.dataset.id,
      })
    },
  }
})
